import { ref, provide, readonly } from 'vue'
import { camelCase } from 'lodash-es'

export default function useProvide(key, val) {
  const property = ref(val)

  provide(key, readonly(property))
  provide(camelCase(`update_${key}`), (newVal) => {
      property.value = newVal
    }
  )

  return {
    key: property,
  }
}
